import java.sql.*;
public class jdbc{
    public static void main(String[] args) {
        Connection conn = null;
        Statement stmt = null;
        try{
            DriverManager.registerDriver(new com.mysql.jdbc.Driver());
            conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/hyd","root","root");
            stmt = conn.createStatement();
            String sql = "update dept set dname = '销售部',loc = '天津' where dept = 20";
            int count = stmt.executeUpdate(sql);
            System.out.println(count==1?"删除成功":"删除失败");
        }catch(SQLException e){
            e.printStackTrace();
        }finally{
            if(stmt != null){
                try{
                    stmt.close();
                }catch(SQLException e){
                    e.printStackTrace();
                }
            }
            if(conn != null){
                try{
                    conn.close();
                }catch(SQLException e){
                    e.printStackTrace();
                }
            }
        }
    }

}